<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\Banner;
/* @var $this yii\web\View */
/* @var $searchModel common\models\BannerSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '广告';
$this->params['breadcrumbs'][] = $this->title;
?>
 <?= Html::csrfMetaTags() ?>
  <?php $this->head() ?>
<?= $this->params['w_config']['statistics_code'] //统计代码?>
<div class="banner-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('添加广告', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
           
            'id',
            [
                'attribute' => 'pid',
                'value' => function ($model, $key, $index, $column) {
                    return Banner::itemAlias("pid", $model->pid);
                },
                'filter'=>Banner::itemAlias("pid"),
            ],   
            //'name',
            'link',
            'position_desc',
             [
                'attribute' => 'img_url',
                'format' => 'image',
                'value'=>function($model) { return $model->img_url.'!s100'; },
            ],
             'width',
             'height',
            // 'end_time',
            // 'man',
            // 'email:email',
            // 'phone',
            // 'click_count',
             [
                'attribute' => 'enabled',
                'value' => function ($model, $key, $index, $column) {
                    return Banner::itemAlias("enabled", $model->enabled);
                },
                'filter'=>Banner::itemAlias("enabled"),
            ],   
            'orderby',
            [
                'attribute' => 'target',
                'value' => function ($model, $key, $index, $column) {
                    return Banner::itemAlias("target", $model->target);
                },
                'filter'=>Banner::itemAlias("target"),
            ],   
                'creat_time',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
